package com.sl.au.repository;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import com.sl.au.entity.Customer;
import com.sl.au.entity.KeyContact;

public interface KeyContactRepository extends JpaRepository<KeyContact, String> {
	/// 关键人物查询
	@Query(" select k from KeyContact k where k.customer.id=?1 and k.name like '%'+?2+'%' ")
	Page<KeyContact> findKeyContact(String id,String key, Pageable pageable);
	
	@Query(" select k from KeyContact k where k.customer.id=?1")
	Page<KeyContact> findKeyContact(String id,Pageable pageable);
	
	@Query(" select k from KeyContact k where k.customer.id=?1")
	List<KeyContact> findKeyContacts(String id);
	
	//关键人物条数
	@Query(" select count(k) from KeyContact k where k.customer.id=?1 and k.name like '%'+?2+'%' ")
	Long getKeyCount(String id,String key);
	
	@Query(" select count(k) from KeyContact k where k.customer.id=?1")
	Long getKeyCount(String id);
}
